﻿namespace WebPacker.VersionGenerators
{
	using System;
	using WebPacker.Helpers;
	using WebPacker.Packs;

	public sealed class Md5VersionGenerator : IVersionGenerator
	{
		public Md5VersionGenerator()
		{
			Name = "md5";
		}

		public string Name { get; set; }

		public string GetNextVersion(Pack pack)
		{
			if (pack == null)
			{
				throw new ArgumentNullException("pack");
			}

			if (pack.Resources.Length == 0)
			{
				return string.Empty;
			}

			return HashHelper.ComputeMd5HashString(pack.GetSourceContent());
		}
	}
}
